package os

import (
	"bytes"
	"fmt"
	"os/exec"
	"runtime"
	"strings"
)

type Person struct {
	Name string
	Age  int
}

func (p *Person) SayHi(name string) string {
	fmt.Printf("hello %s,I'am %s,nice to meet you!\n", name, p.Name)
	return name
}

func Exec(command string) (string, string, error) {
	var stdout bytes.Buffer
	var stderr bytes.Buffer

	ShellToUse := []string{"bash", "-c"}

	ost := runtime.GOOS
	if strings.EqualFold(ost, "windows") {
		ShellToUse = []string{"cmd", "/C"}
	}

	cmd := exec.Command(ShellToUse[0], ShellToUse[1], command)

	cmd.Stdout = &stdout
	cmd.Stderr = &stderr
	err := cmd.Run()

	return stdout.String(), stderr.String(), err
}
